from api.login import LoginAPI
from api.course import CourseAPI

class TestUpdateCourseAPI:
    TOKEN = None
    #登录
    def setup_method(self):
        self.login_api =LoginAPI()
        self.course_api =CourseAPI()
        response_v = self.login_api.get_verify_code()
        login_data = {
            "username": "admin",
            "password": "HM_2023_test",
            "code": 2,
            "uuid": response_v.json().get("uuid")
        }
        response_l = self.login_api.login(test_data=login_data)
        TestUpdateCourseAPI.TOKEN = response_l.json().get("token")
        print(TestUpdateCourseAPI)
    #课程修改成功
    def test01_update_success(self):
        update_data={
            "id":109,
            "name": "课程测试001"
        }
        response = self.course_api.update_course(test_data=update_data,token=TestUpdateCourseAPI.TOKEN)
        print(response.json())
        assert 200 ==response.status_code
        assert "成功" in response.text
        assert 200 ==response.json().get("code")
    def test02_update_fail(self):
        pass